package com.ruoyi.quartz.task;

import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.edh.domain.EdhGoods;
import com.ruoyi.edh.domain.EdhProfit;
import com.ruoyi.edh.domain.EdhShoppingCart;
import com.ruoyi.edh.mapper.EdhCouponMapper;
import com.ruoyi.edh.mapper.EdhGoodsMapper;
import com.ruoyi.edh.mapper.EdhMicroshopGoodsMapper;
import com.ruoyi.edh.mapper.EdhProfitMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import com.ruoyi.common.utils.StringUtils;

/**
 * 定时任务调度测试
 * 
 * @author ruoyi
 */
@Component("ryTask")
@Slf4j
public class RyTask
{
    public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i)
    {
        System.out.println(StringUtils.format("执行多参方法： 字符串类型{}，布尔类型{}，长整型{}，浮点型{}，整形{}", s, b, l, d, i));
    }

    public void ryParams(String params)
    {
        System.out.println("执行有参方法：" + params);
    }

    public void ryNoParams()
    {
        System.out.println("执行无参方法");
    }


    /*易订货 - 今日收益清空*/
    public void clearTodaybenefits(){
        EdhProfitMapper edhProfitMapper = SpringUtils.getBean(EdhProfitMapper.class);
        Integer integer = edhProfitMapper.clearToDayBenefits();
    }
    /**易订货 - 商品排期*/
    public void scheduledGoods(){
        log.info("-------------------商品排期开始执行---------------------------");
        EdhGoodsMapper goodsMapper = SpringUtils.getBean(EdhGoodsMapper.class);
        EdhMicroshopGoodsMapper microshopGoodsMapper = SpringUtils.getBean(EdhMicroshopGoodsMapper.class);
        goodsMapper.openResellByScheduled();
        goodsMapper.closeResellByScheduled();
        /** 团长上架的商品设置为无效状态*/
        microshopGoodsMapper.killMicroGoods();
        /** 购物车商品失效*/
        microshopGoodsMapper.getMicroGoodsByScheduled().forEach(EdhShoppingCart::killGoodsBymircoGoodsId);
        log.info("-------------------商品排期执行结束---------------------------");
    }
}
